import {FC,Suspense} from "react";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { RouteRawState } from "../types";
import { routes } from "./routes";
const routerView = (routes: RouteRawState[]) => {
  return routes.map((v, i) => {
    return (
      <Route path={v.path} element={v.element} key={i}>
        {v.children && routerView(v.children)}
      </Route>
    );
  });
};
const Index: FC = () => {
  return (
    <BrowserRouter>
      <Suspense>
        <Routes>{routerView(routes)}</Routes>
      </Suspense>
    </BrowserRouter>
  );
};
export default Index;
